package com.zhengsr.wanandroid.activity;

import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.zhengsr.corelib.bean.LogUpBean;
import com.zhengsr.wanandroid.R;
import com.zhengsr.wanandroid.mvp.base.BaseActivity;
import com.zhengsr.wanandroid.mvp.contract.ContractManager;
import com.zhengsr.wanandroid.mvp.present.LoginPresent;

import butterknife.BindView;
import butterknife.OnClick;

public class LoginUpActivity extends BaseActivity<LoginPresent> implements ContractManager.ILogUpView {

    private LoginPresent mPresent;
    @BindView(R.id.common_toolbar)
    Toolbar mToolbar;

    @BindView(R.id.login_up_name)
    EditText mUserName;
    @BindView(R.id.login_up_password)
    EditText mPassword;
    @BindView(R.id.login_up_c_pass)
    EditText mRePassword;

    @Override
    public int getLayoutId() {
        return R.layout.activity_loginup;
    }

    @Override
    public LoginPresent getPresent() {
        mPresent = LoginPresent.create(this);
        return mPresent;
    }

    @Override
    public void initView() {
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @OnClick(R.id.login_up_btn)
    void onClickEvent(View view){
        if (view.getId() == R.id.login_up_btn){
            String username = mUserName.getText().toString();
            String password = mPassword.getText().toString();
            String rePassword = mRePassword.getText().toString();
            mPresent.register(username,password,rePassword);
        }
    }

    @Override
    public void logUpSuccess(LogUpBean bean) {
      // Lgger.d("zsr --> logupscess: "+bean.toString());
       Toast.makeText(this, "注册工程", Toast.LENGTH_SHORT).show();
       finish();
    }
}
